package com.arrogames.blondbattle.game.movement
{
	import flash.geom.Point;
	
	public class Motion
	{
		public var velocity : Point = new Point();
		public var angularVelocity : Number = 0;
		public var damping : Number = 0;
		
		private var oldVelocity:Point = null;
		private var oldAngularVelocity:Number = 0;
		private var stopped:Boolean = false;
		
		public function Motion( velocityX : Number, velocityY : Number, angularVelocity : Number, damping : Number )
		{
			velocity = new Point( velocityX, velocityY );
			this.angularVelocity = angularVelocity;
			this.damping = damping;
		}
		
		public function stop() : void
		{
			rememberOldPosition();
			velocity.x = velocity.y = 0;
			angularVelocity = 0;
			stopped = true;
		}
		
		public function move() : void
		{
			if(null != oldVelocity) {
				velocity = oldVelocity; 
				angularVelocity = oldAngularVelocity;
			}
			stopped = false;
		}
		
		public function rememberOldPosition() : void
		{
			oldVelocity = new Point(velocity.x, velocity.y);
			oldAngularVelocity = angularVelocity;
		}
		
		public function isStopped() : Boolean
		{
			return stopped;
		}
	}
}
